package com.whmskj.xjlhbc.service.impl;

import cn.hutool.core.date.BetweenFormatter;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.whmskj.xjlhbc.domain.*;
import com.whmskj.xjlhbc.mapper.*;
import com.whmskj.xjlhbc.mobile.GetStartDate;
import com.whmskj.xjlhbc.service.*;
import com.whmskj.xjlhbc.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class BoardServiceImpl implements IBoardService {

    @Autowired
    private BoardMapper boardMapper;

    @Autowired
    private IMachineInfoService machineInfoService;

    @Autowired
    private IBy01MaintenanceScheduleService by01MaintenanceScheduleService;

    @Autowired
    private ISchedulingOfSbbx01MalfunctionRepService schedulingOfSbbx01MalfunctionRepService;

    @Autowired
    private StopdataInfoMapper stopdataInfoMapper;

    @Autowired
    private MeszjjMapper meszjjMapper;

    @Autowired
    private MesjsjMapper mesjsjMapper;

    @Autowired
    private HomeMapper homeMapper;

    @Autowired
    private MesdbRealMapper mesdbRealMapper;

    @Autowired
    private MesktMapper mesktMapper;

    @Autowired
    private TvLargeScreenMapper mapper;

    @Autowired
    private ITvLargeScreenService tvLargeScreenService;


    @Override
    public KbClVo clkb() {
        String now = DateUtil.today();
        KbClVo vo = new KbClVo();
        JtKbVo.Top left = Optional.ofNullable(boardMapper.select(getClassName(),now)).orElse(new JtKbVo.Top());
        String start = DateUtil.beginOfWeek(new Date()).toDateStr();
        String end = DateUtil.endOfWeek(new Date()).toDateStr();
        String yesterday = DateUtil.yesterday().toDateStr();
        JtKbVo.Top right = vo.getRight();
        right.setCount1(boardMapper.selectDate(now));
        right.setCount2(boardMapper.selectDate(yesterday));
        double sum = boardMapper.selectWeek(start, end);
        right.setCount3(String.format("%.2f", sum / 10000.0));
        sum = boardMapper.selectMonth(LocalDate.now().minusMonths(1).withDayOfMonth(21).toString(), LocalDate.now().withDayOfMonth(20).toString());
        right.setCount4(String.format("%.2f", sum / 10000.0));
        sum = boardMapper.selectYear(DateUtil.date().year());
        right.setCount5(String.format("%.2f", sum / 10000.0));
        vo.setLeft(left);
        setCldbChart(vo);
        setClqxChart(vo);
        setTableList(vo);
        setTableList2(vo);
        return vo;
    }

    @Override
    public KbSbVo sbkb() {
        KbSbVo vo = new KbSbVo();
        JtKbVo jtKbVo = machineInfoService.jtKb();
        List<Object> jtList = jtKbVo.getJtList();
        vo.setLeft(jtKbVo.getLeft());
        JtKbVo.Top center = vo.getCenter();
        center.setCount1(getCount(1,jtList));
        center.setCount2(getCount(2,jtList));
        center.setCount3(getCount(3,jtList));
        center.setCount4(getCount(4,jtList));

        String now = LocalDate.now().toString();
        JtKbVo.Top right = vo.getRight();
        List<String> month = getMonth();
        List<By01MaintenanceSchedule> wb = getWb(month);
        List<SchedulingOfSbbx01MalfunctionRep> gz = getGz(month);
        right.setCount1(wb.stream().filter(f->f.getVsDate().equals(now)).count());
        right.setCount2(gz.stream().filter(f->f.getMaintenanceDate().contains(now)).count());
        right.setCount3(wb.stream().filter(f->f.getVsDate().contains(now.substring(0,7))).count());
        right.setCount4(gz.stream().filter(f->f.getMaintenanceDate().contains(now.substring(0,7))).count());

        List<Double> value = new ArrayList<>();
        List<Double> value2 = new ArrayList<>();
        List<StopdataInfo> stop = getStop(month);
        month.forEach(m->{
            value.add((double) wb.stream().filter(f->f.getVsDate().equals(m)).count());
            value2.add((double) stop.stream().filter(f->f.getTs().equals(m)).findFirst().orElseGet(StopdataInfo::new).getStopcount_other());
        });
        HomeVo.Chart chart1 = vo.getChart1();
        chart1.setXAxisData(month);
        chart1.setValue(Collections.singletonList(value));
        HomeVo.Chart chart2 = vo.getChart2();
        chart2.setXAxisData(month);
        chart2.setValue(Collections.singletonList(value2));
        vo.setChart3(stop());
        vo.setChart4(boardMapper.selectgzlx());
        List<Map<String, String>> list = boardMapper.selectTj();
        list.forEach(l->{
            long time = NumberUtil.parseLong(l.get("time"));
            l.put("time", DateUtil.formatBetween(time * 1000, BetweenFormatter.Level.SECOND));
        });
        vo.getTableList().addAll(list);
        return vo;
    }

    @Override
    public List<ThePlanesStrappedToATable> ktkb() {
        return boardMapper.selectKtkb(getClassName(),DateUtil.today());
    }


    @Override
    public KbZzcjVo zzcjkb() {
        List<Meszjj> meszjjs = meszjjMapper.selectList(null);
        List<Mesjsj> mesjsjs = mesjsjMapper.selectList(null);
        LambdaQueryWrapper<MesdbReal> mesdbRealLambdaQueryWrapper = new LambdaQueryWrapper<>();
        mesdbRealLambdaQueryWrapper.in(BaseEntity::getMacname, "db3");
        List<MesdbReal> mesdbRealList = mesdbRealMapper.selectList(mesdbRealLambdaQueryWrapper);
        double zdh = mesdbRealList.stream().filter(f->f.getDbname().equals("总表")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();

        LambdaQueryWrapper<Meskt> mesktLambdaQueryWrapper = new LambdaQueryWrapper<>();
        mesktLambdaQueryWrapper.eq(BaseEntity::getMacid, 5).last("limit 1");
        Meskt kt = Optional.ofNullable(mesktMapper.selectOne(mesktLambdaQueryWrapper)).orElseGet(Meskt::new);

        KbZzcjVo vo = new KbZzcjVo();
        JtKbVo.Top left = vo.getLeft();
        left.setCount1(meszjjs.stream().mapToLong(m->NumberUtil.parseLong(m.getA393())).sum());
        left.setCount2(mesjsjs.stream().mapToLong(Mesjsj::getA213).sum());
        left.setCount3(String.format("%.2f",zdh));
        JtKbVo.Top center = vo.getCenter();
        center.setCount1(41);
        center.setCount2(0);
        center.setCount3(0);
        center.setCount4(0);
        center.setCount5(0);

        JtKbVo.Top right = vo.getRight();
        right.setCount1(kt.getWd());
        right.setCount2(kt.getSd());

        HomeVo.Chart chart1 = vo.getChart1();
        List<List<Double>> value = chart1.getValue();
        List<String> date = getDate();
        List<Double> v = new ArrayList<>();
        List<Double> v1 = new ArrayList<>();
        List<Double> v2 = new ArrayList<>();
        date.forEach(d->{
            Map<String, Object> dhMap = Optional.ofNullable(mapper.selectDhByDateRange(d+" 00:00:00", d+" 23:00:00")).orElseGet(HashMap::new);
            double zjdhBz = NumberUtil.parseDouble(String.valueOf(dhMap.get("zj")),0.0);
            double jsdhBz = NumberUtil.parseDouble(String.valueOf(dhMap.get("js")),0.0);
            double gldhBz = NumberUtil.parseDouble(String.valueOf(dhMap.get("gl")),0.0);
            v.add(zjdhBz);
            v1.add(jsdhBz);
            v2.add(gldhBz);
        });
        value.add(v);
        value.add(v1);
        value.add(v2);
        chart1.setXAxisData(date);
        chart1.setValue(value);
        setChart(vo);
        setCqxx(vo);
        setTableList(vo);
        return vo;
    }

    @Override
    public Object chkb() {
        Map<String, Object> resultMap = new HashMap<>();
        LambdaQueryWrapper<MesdbReal> mesdbRealLambdaQueryWrapper = new LambdaQueryWrapper<>();
        mesdbRealLambdaQueryWrapper.in(BaseEntity::getMacname, "db3");
        List<MesdbReal> mesdbRealList = mesdbRealMapper.selectList(mesdbRealLambdaQueryWrapper);
        double zdh = mesdbRealList.stream().filter(f->f.getDbname().equals("总表")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double zjdh = mesdbRealList.stream().filter(f->f.getDbname().contains("整经")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double jsdh = mesdbRealList.stream().filter(f->f.getDbname().contains("浆纱")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double gldh = mesdbRealList.stream().filter(f->f.getDbname().contains("锅炉")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double zmdh = mesdbRealList.stream().filter(f->f.getDbname().contains("照明")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        Map<String, Object> chMap = new HashMap<>();
        chMap.put("zdh", String.format("%.2f",zdh));
        chMap.put("zjdh", String.format("%.2f",zjdh));
        chMap.put("jsdh", String.format("%.2f",jsdh));
        chMap.put("gldh", String.format("%.2f",gldh));
        chMap.put("zmdh", String.format("%.2f",zmdh));

        DateTime date = DateUtil.date();
        int month = GetStartDate.getMonthValue();
        int year = date.year();
        Map<String, Object> cjchMap = boardMapper.selectCjch(month,year);//车间产耗
        DateTime beginOfWeek = DateUtil.beginOfWeek(date);
        DateTime endOfWeek = DateUtil.endOfWeek(date);
        List<Map<String, Object>> cldbMap = boardMapper.selectCldb(beginOfWeek.toString(),endOfWeek.toString());
        List<Map<String, Object>> bznhMap = boardMapper.selectBznh(beginOfWeek.toString(),endOfWeek.toString());

        List<String> months = getMonth();
        List<Map<String, Object>> clqxMap = boardMapper.selectClqx(months.get(0),months.get(months.size()-1));
        List<Map<String, Object>> dhqxMap = boardMapper.selectDhqx(months.get(0),months.get(months.size()-1));//电耗曲线
        List<List<Map<String, Object>>> clqxList = Arrays.asList(clqxMap, dhqxMap);

        resultMap.put("ch", chMap);
        resultMap.put("cjch", cjchMap);
        resultMap.put("cldb", cldbMap);
        resultMap.put("bznh", bznhMap);
        resultMap.put("clqx", clqxList);
        return resultMap;
    }

    @Override
    public Object nhkb() {
        Map<String, Object> resultMap = new HashMap<>();
        LambdaQueryWrapper<MesdbReal> mesdbRealLambdaQueryWrapper = new LambdaQueryWrapper<>();
        List<MesdbReal> dbList = mesdbRealMapper.selectList(mesdbRealLambdaQueryWrapper);
        List<MesdbReal> mesdbRealList = dbList.stream().filter(f -> f.getMacname().equals("db3")).collect(Collectors.toList());
        List<MesdbReal> mesdbRealList1 = dbList.stream().filter(f -> !f.getMacname().equals("db3")).collect(Collectors.toList());
        Map<String, Object> zzMap = new HashMap<>();//准整车间
        Map<String, Object> zbMap = new HashMap<>();//织布车间
        double dh1 = mesdbRealList.stream().filter(f->f.getDbname().equals("总表")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double dh2 = mesdbRealList.stream().filter(f->f.getDbname().contains("整经")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double dh3 = mesdbRealList.stream().filter(f->f.getDbname().contains("浆纱")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double dh4 = mesdbRealList.stream().filter(f->f.getDbname().contains("锅炉")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double dh5 = mesdbRealList.stream().filter(f->f.getDbname().contains("照明")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        zzMap.put("dh1", String.format("%.2f",dh1));
        zzMap.put("dh2", String.format("%.2f",dh2));
        zzMap.put("dh3", String.format("%.2f",dh3));
        zzMap.put("dh4", String.format("%.2f",dh4));
        zzMap.put("dh5", String.format("%.2f",dh5));

        double dh11 = mesdbRealList1.stream().filter(f->f.getDbname().equals("总表")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double dh21 = mesdbRealList1.stream().filter(f->f.getDbname().contains("织布")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double dh31 = mesdbRealList1.stream().filter(f->f.getDbname().contains("空压机")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double dh41 = mesdbRealList1.stream().filter(f->f.getDbname().contains("空调")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double dh51 = mesdbRealList1.stream().filter(f->f.getDbname().contains("照明")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        double dh6 = mesdbRealList1.stream().filter(f->f.getDbname().contains("消防")).mapToDouble(m -> NumberUtil.parseDouble(m.getDay(), 0.0)).sum();
        zbMap.put("dh1", String.format("%.2f",dh11));
        zbMap.put("dh2", String.format("%.2f",dh21));
        zbMap.put("dh3", String.format("%.2f",dh31));
        zbMap.put("dh4", String.format("%.2f",dh41));
        zbMap.put("dh5", String.format("%.2f",dh51));
        zbMap.put("dh6", String.format("%.2f",dh6));

        List<String> months = getMonth();
        List<Map<String, Object>> qxMap = boardMapper.selectNhdb(months.get(0),months.get(months.size()-1));//电耗对比
        Map<String, Object> gxdhMap = boardMapper.selectGxdh(months.get(0),months.get(months.size()-1));//各工序电耗占比

        DateTime date = DateUtil.date();
        DateTime beginOfWeek = DateUtil.beginOfWeek(date);
        DateTime endOfWeek = DateUtil.endOfWeek(date);
        String beginOfMonth = GetStartDate.getMonthStartDate();
        DateTime endOfMonth = DateUtil.endOfMonth(date);
        DateTime beginOfYear = DateUtil.beginOfYear(date);
        DateTime endOfYear = DateUtil.endOfYear(date);

        List<Map<String, Object>> keyList = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("name", "织布");
        map.put("key", "zb");
        map.put("br", dh21);
        keyList.add(map);
        map = new HashMap<>();
        map.put("name", "整经");
        map.put("key", "zj");
        map.put("br", dh2);
        keyList.add(map);
        map = new HashMap<>();
        map.put("name", "浆纱");
        map.put("key", "js");
        map.put("br", dh3);
        keyList.add(map);
        map = new HashMap<>();
        map.put("name", "锅炉房");
        map.put("key", "gl");
        map.put("br", dh4);
        keyList.add(map);
        map = new HashMap<>();
        map.put("name", "空压机");
        map.put("key", "kyj");
        map.put("br", dh31);
        keyList.add(map);

        List<List<Object>> ljMap = keyList.stream().map(item -> {
            String key = item.get("key").toString();
            Map<String, Object> gxdh = Optional.ofNullable(boardMapper.selectGxdh(beginOfWeek.toString(), endOfWeek.toString())).orElseGet(HashMap::new);
            double bz = NumberUtil.parseDouble(String.valueOf(gxdh.get(key)), 0.0);
            gxdh = Optional.ofNullable(boardMapper.selectGxdh(beginOfMonth, endOfMonth.toString())).orElseGet(HashMap::new);
            double by = NumberUtil.parseDouble(String.valueOf(gxdh.get(key)), 0.0);
            gxdh = Optional.ofNullable(boardMapper.selectGxdh(beginOfYear.toString(), endOfYear.toString())).orElseGet(HashMap::new);
            double bn = NumberUtil.parseDouble(String.valueOf(gxdh.get(key)), 0.0);
            return Arrays.asList(item.get("name"), item.get("br"), bz, by, bn);
        }).collect(Collectors.toList()); //累计数据
        resultMap.put("zz", zzMap);
        resultMap.put("zb", zbMap);
        resultMap.put("dhdb", qxMap);
        resultMap.put("dhqx", qxMap);
        resultMap.put("gxdh", gxdhMap);
        resultMap.put("ljsj", ljMap);
        return resultMap;
    }

    private void setChart(KbZzcjVo vo){
        List<String> data = Arrays.asList("整经", "浆纱");
        List<String> xAxisData = getDate();
        List<List<Double>> value = new ArrayList<>();
        HomeVo.Chart chart2 = vo.getChart2();
        chart2.setXAxisData(xAxisData);
        chart2.setData(data);

        List<Double> doubleList = new ArrayList<>();
        List<Double> doubleList1 = new ArrayList<>();
        xAxisData.forEach(date->{
            doubleList.add(homeMapper.selectZj(date));
            doubleList1.add(homeMapper.selectJs(date));
        });
        value.add(doubleList);
        value.add(doubleList1);
        chart2.setValue(value);
    }

    private void setTableList(KbZzcjVo vo){
        List<Object> tableList = vo.getTableList();
        Map<String,Object> map = (Map<String, Object>) tvLargeScreenService.get3();
        List<Map<String,Object>> list = (List<Map<String, Object>>) map.get("ljsj");
        tableList.addAll(list);
    }

    private void setCqxx(KbZzcjVo vo){
        HomeVo.Cqxx cqxx = vo.getGwry();
        String workshop = "准整车间";
        cqxx.setTotal(homeMapper.selectPersonnelTotal(workshop));
        cqxx.setCq(homeMapper.selectPersonnel(workshop,"出勤"));
        cqxx.setQq(homeMapper.selectPersonnel(workshop,"缺勤"));
        cqxx.setXx(homeMapper.selectPersonnel(workshop,"休息"));
        cqxx.setLz(homeMapper.selectPersonnel(workshop,"离职"));
        cqxx.setList(homeMapper.selectPersonnelList(workshop));
    }

    private List<Map<String, String>> stop() {
        String date = LocalDate.now().toString();
        LambdaQueryWrapper<StopdataInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StopdataInfo::getTs,date);
        List<StopdataInfo> stopdataInfoList = stopdataInfoMapper.selectList(queryWrapper);
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map = new HashMap<>();
        long stopcount = stopdataInfoList.stream().mapToInt(StopdataInfo::getStopcount_weft_short).sum();
        map.put("name", "短纬停");
        map.put("value", String.valueOf(stopcount));
        list.add(map);

        map = new HashMap<>();
        stopcount = stopdataInfoList.stream().mapToInt(StopdataInfo::getStopcount_weft_long).sum();
        map.put("name", "长纬停");
        map.put("value", String.valueOf(stopcount));
        list.add(map);
        map = new HashMap<>();
        stopcount = stopdataInfoList.stream().mapToInt(StopdataInfo::getStopcount_warp).sum();
        map.put("name", "经停");
        map.put("value", String.valueOf(stopcount));
        list.add(map);

        map = new HashMap<>();
        stopcount = stopdataInfoList.stream().mapToInt(StopdataInfo::getStopcount_other).sum();
        map.put("name", "其它");
        map.put("value", String.valueOf(stopcount));
        list.add(map);
        return list;
    }

    private List<By01MaintenanceSchedule> getWb(List<String> month){
        String start = month.get(0);
        String end = month.get(month.size() - 1);
        LambdaQueryWrapper<By01MaintenanceSchedule> wrapper = new LambdaQueryWrapper<>();
        wrapper.between(By01MaintenanceSchedule::getVsDate, start, end);
        return by01MaintenanceScheduleService.list(wrapper);
    }

    private List<SchedulingOfSbbx01MalfunctionRep> getGz(List<String> month){
        String start = month.get(0);
        String end = month.get(month.size() - 1);
        LambdaQueryWrapper<SchedulingOfSbbx01MalfunctionRep> wrapper = new LambdaQueryWrapper<>();
        wrapper.between(SchedulingOfSbbx01MalfunctionRep::getMaintenanceDate, start, end);
        return schedulingOfSbbx01MalfunctionRepService.list(wrapper);
    }

    private List<StopdataInfo> getStop(List<String> month){
        String start = month.get(0);
        String end = month.get(month.size() - 1);
        return boardMapper.selectStop(start, end);
    }

    private long getCount(int xl,List<Object> jtList){
        double min = 0;
        double max = 0;
        if(xl == 1){
            min = 95;max = 100;
        }
        if(xl == 2){
            min = 90;max = 95;
        }
        if(xl == 3){
            min = 85;max = 90;
        }
        if(xl == 4){
            min = 0;max = 85;
        }
        double finalMin = min;
        double finalMax = max;
        return jtList.stream().filter(f->{
            RundataInfo rundataInfo = (RundataInfo) f;
            Double efficiency = rundataInfo.getEfficiency();
            return efficiency >= finalMin && efficiency <= finalMax;
        }).count();
    }

    private String getClassName(){
        int hour = DateUtil.date().hour(true);
        String classes = hour >= 9 && hour < 21 ? "早" : "晚";
        LocalDate now = LocalDate.now();
        if(hour<9){
            now = now.minusDays(1);
        }
        String str = boardMapper.selectCurrentClassName(classes, now.toString());
        return str.contains("甲") ? "甲" : "乙";
    }

    private void setCldbChart(KbClVo vo){
        List<String> data = Arrays.asList("甲", "乙");
        List<String> xAxisData = getDate();
        List<List<Double>> value = new ArrayList<>();
        HomeVo.Chart cldbChart = vo.getChart1();
        cldbChart.setXAxisData(xAxisData);
        cldbChart.setData(data);

        List<Statistics> statistics = boardMapper.selectCl(xAxisData.get(0),xAxisData.get(xAxisData.size() - 1));
        data.forEach(classes->{
            List<Double> doubleList = new ArrayList<>();
            xAxisData.forEach(date-> {
                double v = statistics.stream().filter(f -> f.getClassname().equals(classes) && f.getDateymd().equals(date))
                        .mapToDouble(m -> NumberUtil.parseDouble(m.getClothlength())).sum();
                doubleList.add(v);
            });
            value.add(doubleList);
        });
        cldbChart.setValue(value);
    }

    private void setClqxChart(KbClVo vo){
        List<String> xAxisData = getMonth();
        List<List<Double>> value = new ArrayList<>();
        HomeVo.Chart clqxChart = vo.getChart2();
        clqxChart.setXAxisData(xAxisData);
        List<Double> doubleList = new ArrayList<>();
        List<Statistics> statistics = boardMapper.selectCl(xAxisData.get(0),xAxisData.get(xAxisData.size() - 1));
        xAxisData.forEach(date-> {
            double v = statistics.stream().filter(f -> f.getDateymd().equals(date))
                    .mapToDouble(m -> NumberUtil.parseDouble(m.getClothlength())).sum();
            doubleList.add(v);
        });
        value.add(doubleList);
        clqxChart.setValue(value);
    }

    private void setTableList(KbClVo vo){
        List<String> xAxisData = getMonth();
        List<Statistics> tableList = boardMapper.selectJtcl(xAxisData.get(0),xAxisData.get(xAxisData.size() - 1));
        vo.setTableList1(tableList);
    }

    private void setTableList2(KbClVo vo){
        int year = DateUtil.date().year();
        int month = DateUtil.date().monthBaseOne();
        List<Map<String,String>> tableList = boardMapper.selectJtcl1(year,month);
        vo.getTableList2().addAll(tableList);
    }

    private List<String> getDate(){
        LocalDate end = LocalDate.now();
        LocalDate start = end.minusDays(6);
        List<String> dates = new ArrayList<>();
        while(!start.isAfter(end)){
            dates.add(start.toString());
            start = start.plusDays(1);
        }
        return dates;
    }

    private List<String> getMonth(){
        LocalDate end = LocalDate.now();
        LocalDate start = end.minusDays(30);
        List<String> dates = new ArrayList<>();
        while(!start.isAfter(end)){
            dates.add(start.toString());
            start = start.plusDays(1);
        }
        return dates;
    }
}
